package com.foruo.sc.log.server.rabbit;

import com.foruo.sc.log.server.config.RabbitServerConfig;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * 发送者
 * @author GaoYuan
 * @date 2018/4/9 下午4:06
 */
@Component
public class Sender {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send() {
        String context = "hello " + new Date();
        System.out.println("Sender : " + context);
        String message = "{\"createDate\":1523261436925,\"ip\":\"0:0:0:0:0:0:0:1\",\"method\":\"com.raising.sc.log.web.DemoController.postBlog()\",\"operation\":\"执行某某操作\",\"username\":\"gaoyuan\"}";
        rabbitTemplate.convertAndSend(RabbitServerConfig.queueName, message);
    }

}